//package mongo;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.Collection;
//import java.util.LinkedList;
//import java.util.List;
//
//@RestController
//@RequestMapping("/mongo/")
//public class MongoController {
//
//    @Autowired
//    private MongoUserRepository userRepository;
//
//    @PostMapping("/")
//    public MongoUser save() {
//        MongoUser user = new MongoUser("1", "tuyou", (short)27);
//        Collection<Location> locations = new LinkedList<>();
//        Location l1 = new Location("上海", "2009");
//        Location l2 = new Location("北京", "2018");
//        Location l3 = new Location("成都", "2019");
//        locations.add(l1);
//        locations.add(l2);
//        locations.add(l3);
//        user.setLocations(locations);
//
//        userRepository.save(user);
//        return user;
//    }
//
//    @GetMapping("/q1")
//    public MongoUser q1(String name) {
//        return userRepository.findByName(name);
//    }
//
//    @GetMapping("/q2")
//    public List<MongoUser> q1(Short age) {
//        return userRepository.findByAge(age);
//    }
//}
